#ifndef __TWEAKS_PLUGIN_H__
#define __TWEAKS_PLUGIN_H__

#include <QtGui>
#include <QtNetwork>
#include <QtScript>
#include "PluginInterface.h"
#include "../../core/include/QtScriptPluginInterface.h"
#include "../../core/include/shell.h"

class HomeMenuController;
class NickelTouchMenu;
class GridLibraryView;
class ReadingView;
class N3SettingsExtrasController;

#define CONFIG_PATH "/mnt/onboard/.kobo/koboplugins.ini"


class TestPlugin : public IShellObject, public PluginInterface, public QtScriptPluginInterface
{
Q_OBJECT
    Q_INTERFACES(PluginInterface QtScriptPluginInterface)

public:
    TestPlugin();
    ~TestPlugin();

    QStringList mimeTypes();

    QWidget *reader(void* plugin_state, QWidget *parent = 0);
    ParserInterface *parser();

    QSharedPointer<QSettings> settings();

    void registerObject(QObject *object, QString name);

public slots:
    void windowChanged(int index);
    void open(QString shellFunc);
    void library();
    void bookFooterOpened();
    void bookFooterClosed();
    void updateClock();
    void patchFindBooks();
    void patchReadingLife();
    void openWikipedia();

    void rvProcessTap(QString cmd);


private:
    bool checkFirmwareVersion();
    void dumpChildren(QObject* pObj, QString propertyName =QString());
    QString getCustomCommandTranslation(QString func);

    Q_INVOKABLE void executeSystemCmd(QString cmd);
    Q_INVOKABLE void openBrowser();
    Q_INVOKABLE void connectWifi();
    Q_INVOKABLE void toogleAirplaneMode();
    Q_INVOKABLE void uninstallPlugin();
    Q_INVOKABLE void sync(bool);
    Q_INVOKABLE void sleep();
    Q_INVOKABLE void powerOff();
    Q_INVOKABLE void shelves();
    Q_INVOKABLE void readingLife();
    Q_INVOKABLE void sudoku();
    Q_INVOKABLE void chess();
    Q_INVOKABLE void scribble();

private slots:
    void getConnection();

private:
    QSharedPointer<QSettings> pluginSettings;
    HomeMenuController *hmc;
    QSignalMapper mapper;
    QStackedWidget *sw;
    GridLibraryView* m_pglv;
    QWidget* m_pageWidget;
    void *lastPatchedMenu;
    QTimer *m_pClockTimer;
    QScriptEngine engine;
    QTcpSocket *clientConnection;
    QTcpServer *tcpServer;
    QString currentFirmwareVersion;
    QTimer *m_pDumpTimer;
    ReadingView* m_pReadingView;
    N3SettingsExtrasController* m_pExtrasController;
};

#endif
